/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hugoo.test;

import com.hugoo.core.Conf;
import com.hugoo.core.db.Call;
import com.hugoo.core.db.HSF;
import com.hugoo.core.util.LxString;
import java.sql.CallableStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;

/**
 *
 * @author Lovelock.Chan
 */
public class T8 {

    public static void main(String[] args) {
        Conf.reload("/prop/conf.properties");
        for (int i = 0; i < 100; i++) {
            new X().start();
        }
    }
}

class X extends Thread {

    @Override
    public void run() {
        final List<String> ll = new ArrayList<String>(20000);
        for (int i = 0; i < 20000; i++) {
            ll.add(LxString.scod());
        }
        HSF.call(null, new Call() {
            @Override
            public void proc(CallableStatement cs, Log log) throws SQLException {
                for (String l : ll) {
                    cs.setString(1, l);
                    cs.addBatch();
                }
                cs.executeBatch();
                cs.getConnection().commit();
            }

            @Override
            public String procSql() {
                return "insert into emd(scod) values (?)";
            }
        });
    }
}
